package com.codeZ.FactoryPattern.factoryMethod.factory;

import com.codeZ.FactoryPattern.factoryMethod.factory.impl.DiscountFreeGoodsFactory;
import com.codeZ.FactoryPattern.factoryMethod.factory.impl.SmallGiftFreeGoodsFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * 工厂集合类
 *
 * @author codeZhang
 * @Date 2024/8/1 14:51
 */
public class IFreeGoodsFactoryMap {

    private static final Map<Integer, IFreeGoodsFactory> cachedFactories = new HashMap<>();


    static {
        cachedFactories.put(1, new DiscountFreeGoodsFactory());
        cachedFactories.put(2, new SmallGiftFreeGoodsFactory());
    }

    public static IFreeGoodsFactory getParserFactory(Integer type) {
        if (cachedFactories.containsKey(type)) {
            return cachedFactories.get(type);
        }
        return null;
    }

}
